package 设计模式.行为模式.责任链模式;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lchenglong
 * @date 2024/1/25
 */

@Service
public class ModelServiceImpl implements ModelService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource
    private PipelineExecutor pipelineExecutor;

    @Override
    public CommonResponse<Long> buildModelInstance(InstanceBuildRequest request) {
        InstanceBuildContext data = createPipelineData(request);
        boolean success = pipelineExecutor.acceptSync(data);

        // 创建模型实例成功
        if (success) {
            return CommonResponse.success(data.getInstanceId());
        }

        logger.error("创建模式实例失败：{}", data.getErrorMsg());
        return CommonResponse.failure(data.getErrorMsg());
    }

    private InstanceBuildContext createPipelineData(InstanceBuildRequest request){
        return new InstanceBuildContext();
    }
}
